import express, {Express} from "express";
import {articleRouter} from "./ArticleEmbededRouter";
var history = require('connect-history-api-fallback');

export class Application{
    app: Express;
    port: number;

    constructor() {
        this.app = express();
        this.port = 8080;
        //让react支持 history模式，必须放在最前面
        this.app.use('/',history({verbose: true}));
        this.app.use('/article', articleRouter);
        this.app.use(express.static('./dist'));
        this.app.use("/data", express.static('./data'));
    }

    start(){
        this.app.listen(this.port, ()=>{
            console.log(`APP Running at ${this.port}`);
        })
    }
}